#ifndef DW_SYSTEM_THREAD_H
#	define DW_SYSTEM_THREAD_H

namespace dw {
	namespace system {

class Thread
{
public : //! @name Constants
	//! @{
	static const int32 WaitInfinite = INFINITE;
	//! @}

public : //! @name Types Definitions
	//! @{
	enum Priority
	{
		TP_TimeCritical,
		TP_High,
		TP_AboveNormal,
		TP_Normal,
		TP_BelowNormal,
		TP_Low,

		TP_Default = TP_Normal
	};

	enum State
	{
		TS_Invalid = -1,
		TS_Created,
		TS_Running,
		TS_Suspended,
		TS_Terminated
	};
	//! @}

public : //! @name Construction & Destruction
	//! @{
	explicit Thread(const char* name, bool start = true);
	virtual ~Thread();
	//! @}

public : //! @name Commands
	//! @{
	void start();
	bool wait(int32 timeOut = WaitInfinite);
	void suspend();
	void resume();
	void kill();
	//! @}

public : //! @name Setup
	//! @{
	void setPriority(Priority priority);
	//! @}

public : //! @name State
	//! @{
	Priority getPriority() const ;
	//! @}

protected : //! @name Commands
	//! @{
	virtual int run() = 0;
	//! @}

private : //! @name Construction & Destruction
	//! @{
	Thread(const Thread& ref);
	//! @}

private : //! @name Helpers
	//! @{
	void create(bool start);
	void destroy();

	static DWORD WINAPI threadEntryPoint(LPVOID parameter);
	//! @}

private : //! @name Data
	//! @{
	HANDLE _handle;
	DWORD _id;
	Priority _priority;
	State _state;
	//! @}
};

	} // namespace system
} // namespace dw

#endif // !DW_SYSTEM_THREAD_H
